# compiler
CC ?= ${CROSS_COMPILE}gcc
AR ?= ${CROSS_COMPILE}ar
CFLAGS ?= -Wall -O0 -I../include
LDFLAGS ?= -L../lib -lus100 -lgpiox
# libs
LIB_US100 = ../lib/libus100.a
LIB_GPIOX = ../lib/libgpiox.a
LIBS = ${LIB_GPIOX} ${LIB_US100}

PUBLIC_HEADER = ../include/us100.h

DEPEND_DIRS = ../gpiox

OBJS = us100.o demo.o

# default target
defualt: ${DEPEND_DIRS} ${LIB_US100} ${PUBLIC_HEADER} demo

demo: demo.o
	${CC} ${CFLAGS} -o $@ $< ${LDFLAGS}

# libs and objs
.PHONY: ${DEPEND_DIRS}
%.o:
${LIB_US100}: us100.o
	${AR} rcs $@ $^
${DEPEND_DIRS}:
	${MAKE} -C $@
${PUBLIC_HEADER}: us100.h
	cp $< $@

# cleanup
clean:
	${RM} demo
distclean: clean
	${RM} ${OBJS} ${LIB_US100} ${PUBLIC_HEADER}
